import {request} from "../../request/swiper_Request.js";
const db = wx.cloud.database();
// pages/home/home.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		//轮播图数据
		swiperList: [],
		//楼层图数据
		floorList: []
	},
	ajaxTimes:0,
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		/*    wx.request({
		      url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
		      success: (res) => {
		  //  console.log(res);
		        this.setData({
		          swiperList: res.data.message
		        })
		      }
		    }); */
		wx.showLoading();
		this.getSwiper();	
		this.getFloor(); 

	},
 
	//获取轮播图
	getSwiper:function(){
		db.collection('swiper_list').where({}).get()
			.then(result => {
				this.setData({
					swiperList: result.data[0].message,				
				});
				this.ajaxTimes++;
				if(this.ajaxTimes === 2){wx.hideLoading()};
			})
	},
	 
	//获取楼层
	getFloor:function(){
		db.collection('nht_floor').where({}).get()
			.then(result => {
				this.setData({
					floorList: result.data[0].message
				});
				this.ajaxTimes++;
				if(this.ajaxTimes === 2){wx.hideLoading()};
			})
	}

})
